package com.chinaoryx.svn;

import java.util.Collection;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNLogEntry;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

public class SvnManager {
	
	public void testSvn() throws SVNException{
		
		
		DAVRepositoryFactory.setup( );
//		String url = "http://10.50.0.21/svn/havi/Design/DB/Stored Procedure/AutoCheck";
//		String url = "https://database-doc.googlecode.com/svn/trunk";
//		String name = "chinaoryx@gmail.com";
//		String password = "c3w9p9a3";
		
		String url = "http://10.50.0.21/svn/havi/Design/DB/Stored Procedure/AutoCheck";
		String name = "achievo\\hyman.zhang";
		String password = "sybnd0518";
		long startRevision = 0;
		// the latest revision
		long endRevision = -1;
		
		SVNRepository repository = null;
		
		repository = DAVRepositoryFactory.create(SVNURL.parseURIEncoded( url ));
//		ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager( name, password );
		ISVNAuthenticationManager authManager = new BasicAuthenticationManager( name , password);
		

		repository.setAuthenticationManager( authManager );
		
		
		System.out.println(name);
		
		Collection<SVNLogEntry > logEntries = null;		
		logEntries = repository.log( new String[] { "" } , null , startRevision , endRevision , true , true );
		for (SVNLogEntry svnLogEntry : logEntries) {
			System.out.println(svnLogEntry);
		}


	}
	
	public static void main(String[] args) throws SVNException {
		SvnManager obj = new SvnManager();
		obj.testSvn();
	}

}
